/******************************************************************************
 * (c) 2011 Komersi Software                                                  *
 * www.komersisoftware.com                                                    *
 *                                                                            *
 * This file is part of Tadah                                                 *
 * Licensed under GNU General Public License v2.0                             *
 * Check LICENSE.TXT for more information                                     *
 ******************************************************************************/
 
#include <stdlib.h>
#include <string.h>

#include "rowinfo.h"

row_info_t *new_row_info(table_info_t *table)
{
    row_info_t *row = malloc(sizeof(row_info_t));
    if (row == NULL) return NULL;

    memset(row, 0, sizeof(row_info_t));

    row->table = table;
    row->data = NULL;
    row->next = NULL;

    return row;
}

static void add_row(row_info_t **row_list, row_info_t *row)
{
	row_info_t *cur = NULL;
	
    if (*row_list == NULL) 
    {
        *row_list = row;
        return;
    }
      
    cur = *row_list;
    while (cur->next != NULL)
        cur = cur->next;
   
    cur->next = row;
}

row_info_t *add_new_row(row_info_t **row_list, table_info_t *table)
{
    row_info_t *row = NULL;

    row = new_row_info(table);
    add_row(row_list, row);

    return row; 
}
